<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>
<script src="./vue.js"></script>

<body>
  <div id="app">
    <p>总价格：{{totalPrice}}</p>
    <p>单价：{{price}}</p>
    <p>数量：{{count}}</p>
    <div>
      <button @click="count == 0 ? 0 : count--">减少</button>
      <button @click="count++">增加</button>
    </div>
  </div>
  <script>
    const vm = new Vue({
      el: "#app",
      data: {
        price: 20,
        count: 0,
      },
      computed: {
        // 总价格 totalPrice
        totalPrice() {
          return this.price * this.count;
        }
      }
    })
  </script>
</body>

</html>